package com.ruoyi.job.task;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.job.domain.SysJob;
import com.ruoyi.job.service.ISysJobService;
import com.ruoyi.system.api.RemoteBiddingService;
import com.ruoyi.system.api.domain.PcmAudit;
import com.ruoyi.system.api.domain.PcmExpertSupplier;
import com.ruoyi.system.api.domain.PcmInvitedSupplier;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.utils.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{
    @Autowired
    private ISysJobService iSysJobService;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    public void invitationForBidReview(String name,Integer nameId){
        System.out.println("你妈没了"+name+"****"+nameId);
    }

    //修改项目状态
    public void updateProjectStatus(Integer projectInviteId,Integer projectStatus,Integer middleId,Long jobId){

        System.out.println("updateProjectStatus"+jobId);

        //删除相当应的定时任务
        SysJob sysJob = new SysJob();
        sysJob.setJobId(jobId);
        if (projectStatus.equals(3)){
            List<PcmExpertSupplier> pcmExpertSuppliers = iSysJobService.selPcmExpertSupplier(middleId.longValue());
            System.out.println("pcmExpertSuppliers"+pcmExpertSuppliers);
            if (pcmExpertSuppliers!=null&&pcmExpertSuppliers.size()>0){
                pcmExpertSuppliers.forEach(e->{
                    System.out.println("e///////////////"+e);
                    PcmAudit pa = new PcmAudit("评标",e.getExpertSupplierId().toString(),"pcm_expert_supplier",new Date(),e.getExperId());
                    System.out.println(pa+"////////////*************////////////");
                    iSysJobService.addToExamine(pa);
                });
            }
        }
        iSysJobService.updateStatus(projectInviteId.longValue(),projectStatus);
        try {
            iSysJobService.deleteJob(sysJob);
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
    }
}
